package com.EM1.www.util;

import com.EM1.www.dao.ConnectPaper;
import com.EM1.www.dao.ConnectQuestion;
import com.EM1.www.po.Paper;
import com.EM1.www.po.Question;
import com.EM1.www.po.Teacher;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;

public class UpdateSession {
    private UpdateSession(){

    }
    public static void updateQuestion(HttpServletRequest request) throws Exception {
        HttpSession session = request.getSession();
        Teacher teacher = (Teacher) session.getAttribute("teacher");
        ConnectQuestion connectQuestion=new ConnectQuestion();
        ArrayList<Question> questions = connectQuestion.selectAllQuestion(teacher.getId());
        session.setAttribute("questions",questions);
    }
    public static void updatePapers(HttpServletRequest request) throws Exception {
        HttpSession session = request.getSession();
        Teacher teacher = (Teacher) session.getAttribute("teacher");
        ConnectPaper connectPaper=new ConnectPaper();
        ArrayList<Paper> papers = connectPaper.selectPapers(teacher.getId());
        session.setAttribute("papers",papers);
    }
    public static void updatePaper(HttpServletRequest request){
        HttpSession session = request.getSession();
        Paper paper = (Paper)session.getAttribute("paper");
        ConnectQuestion connectQuestion=new ConnectQuestion();

    }
}
